from config import BASE_URL, PHONE, NAME, CARD
from page.page_account import AccountPage
from page.page_register import RegisterPage
from script import log
from tools import DriverTools


class TestAccount(object):

    def setup_method(self):
        # 打开浏览器
        self.driver = DriverTools.get_driver()
        self.driver.get(BASE_URL + "/common/member/reg")  # 注意：登录页面的url
        # 创建对象
        self.reg_page = RegisterPage(self.driver)
        self.account_page = AccountPage(self.driver)

    def teardown_method(self):
        # 关闭浏览器
        DriverTools.quit_driver()

    def test01_open_account_success(self):
        # 注册成功
        self.reg_page.register(PHONE, "Aa123456", "8888")
        # 调用方法：点击...输入...
        self.account_page.open_account(NAME, CARD)  # 身份证号不存在
        # 立即开通页面
        self.account_page.act_account()
        # 打印结果:获取页面窗口、切换窗口、获取内容
        result = self.account_page.get_result_success()
        print(result)
        log.info(f"执行结果：{result}")
        # 断言结果
        assert "OK" in result
